import { request } from './http.js'

// get请求方式是默认,可以忽略
// export const login = (data) => {
// 	return request({
// 		url: '/home/banner',
// 		method: 'post',
// 		data
// 	})
// }

// 轮播图
export const getBannerAPI = (distributionSite = 1) => {
	return request({
		url: '/home/banner',
		data: {
		    distributionSite
		}
	})
}

// nav分类导航
export const getCategoryAPI = () => {
	return request({
		url: '/home/category/mutli'
	})
}

// 商品推荐
export const getHotmutliAPI = () => {
	return request({
		url: '/home/hot/mutli'
	})
}

// 猜你喜欢
export const getGuessLikeAPI = (data) => {
	return request({
		url: '/home/goods/guessLike',
		data
	})
}

// hot 四个推荐的接口
export const getHotRecommendAPI = (url, data) => {
	return request({
		url,
		data
	})
}

// 分类页
export const getCategoryTopAPI = () => {
	return request({
		url: '/category/top'
	})
}

// 商品详情页
export const getGoodsByIdAPI = (id) => {
	return request({
		url: '/goods',
		data:{
			id
		}
	})
}

// 登录
export const postLoginWxMinAPI = (data) => {
	return request({
		url: '/login/wxMin',
		method: 'post',
		data
	})
}
// 登录 内测
export const postLoginWxMinSimpleAPI = (phoneNumber) => {
	return request({
		url: '/login/wxMin/simple',
		method: 'post',
		data:{
			phoneNumber
		}
	})
}


// 获取个人信息
export const getMemberProfileAPI = () => {
	return request({
		url: '/member/profile'
	})
}

// 修改个人信息
export const putMemberProfileAPI = (data) => {
	return request({
		url: '/member/profile',
		method: 'put',
		data
	})
}


// 新增收货地址
export const postMemberAddressAPI = (data) => {
	return request({
		url: '/member/address',
		method: 'post',
		data
	})
}

// 获取收货地址列表
export const getMemberAddressAPI = () => {
	return request({
		url: '/member/address',
		method: 'get'
	})
}

// 修改收货地址 回显
export const getMemberAddressByIdAPI = (id) => {
	return request({
		url: `/member/address/${id}`,
		method: 'get'
	})
}
// 修改收货地址  点击确定按钮
export const putMemberAddressByIdAPI = (id, data) => {
	return request({
		url: `/member/address/${id}`,
		method: 'put',
		data
	})
}
// 删除收货地址
export const deleteMemberAddressByIdAPI = (id) => {
	return request({
		url: `/member/address/${id}`,
		method: 'delete'
	})
}


// 加入购物车
export const postMemberCartAPI = (data) => {
	return request({
		url: '/member/cart',
		method: 'post',
		data
	})
}
// 获取购物车
export const getMemberCartAPI = () => {
	return request({
		url: '/member/cart',
		method: 'get'
	})
}

// 删除购物车单品
export const deleteMemberCartAPI = (data) => {
	return request({
		url: '/member/cart',
		method: 'delete',
		data
	})
}
// 修改购物车单品  这个接口可以修改数量和选中状态
// data: { selected?: boolean; count?: number },
export const putMemberCartBySkuIdAPI = (skuId, data) => {
	return request({
		url: `/member/cart/${skuId}`,
		method: 'put',
		data
	})
}
// 购物车是否全选状态修改
export const putMemberCartSelectedAPI = (data) => {
	return request({
		url: '/member/cart/selected',
		method: 'put',
		data
	})
}


// 获取预付订单 这是在购物车页面点击去结算按钮去到的创建订单页面
export const getMemberOrderPreAPI  = () => {
	return request({
		url: '/member/order/pre'
	})
}
// 获取预付订单 这是在商品详情页面点击立即购买按钮去到的创建订单页面
export const getMemberOrderPreNowAPI  = (data) => {
	return request({
		url: '/member/order/pre/now',
		data
	})
}

// 提交订单
export const postMemberOrderAPI  = (data) => {
	return request({
		url: '/member/order',
		method: 'post',
		data
	})
}

// 获取订单详情
export const getMemberOrderByIdAPI  = (id) => {
	return request({
		url: `/member/order/${id}`,
		method: 'get'
	})
}



// 生产环境：调用正式接口，获取微信支付参数 + 发起微信支付
export const getPayWxPayMiniPayAPI = (data) => {
	return request({
		url: '/pay/wxPay/miniPay',
		method: 'get',
		data
	})
}
// 开发环境：调用模拟接口，通过模拟支付，修改订单状态为已支付
export const getPayMockAPI  = (data) => {
	return request({
		url: '/pay/mock',
		method: 'get',
		data
	})
}

// 在DEV环境下使用，仅在订单状态为待发货时，可模拟发货，调用后订单状态修改为待收货，包含模拟物流。
export const getMemberOrderConsignmentByIdAPI   = (id) => {
	return request({
		url: `/member/order/consignment/${id}`,
		method: 'get'
	})
}
// 确认收货
export const putMemberOrderReceiptByIdAPI = (id) => {
	return request({
		url: `/member/order/${id}/receipt`,
		method: 'put'
	})
}

// 获取物流信息 仅在订单状态为待收货，待评价，已完成时，可获取物流信息。
export const getMemberOrderLogisticsByIdAPI = (id) => {
	return request({
		url:  `/member/order/${id}/logistics`,
		method: 'get'
	})
}

// 删除订单 仅在订单状态为待评价，已完成，已取消时，可删除订单。
export const deleteMemberOrderAPI  = (data) => {
	return request({
		url:  '/member/order',
		method: 'delete',
		data
	})
}

// 订单状态 订单列表页
export const getMemberOrderAPI  = (data) => {
	return request({
		url:  '/member/order',
		method: 'get',
		data
	})
}
